package com.bgs.eat.memberRecord.controller;

import com.bgs.eat.config.CommonResult;
import com.bgs.eat.memberRecord.entity.MemberRecordEntity;
import com.bgs.eat.memberRecord.service.MemberService;
import com.bgs.eat.page.PageRequest;
import com.bgs.eat.page.PageResult;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @ClassName MemberRecordController
 * @Description TODO  购买会员卡记录
 * @Author G胖
 * @Date 2022-10-11 上午 11:21
 **/

@RestController
@CrossOrigin
@RequestMapping("/memberRecord")
public class MemberRecordController {

    @Resource
    MemberService memberService;

    /**
    * @Author G胖
    * @Description 用户界面--购买超级吃货会员（前端）
    * @Date 2022-10-11 下午 07:41
    * @Return com.bgs.eat.config.CommonResult

    */
    @PostMapping("/buyEatMember")
    public CommonResult buyEatMember(@RequestBody MemberRecordEntity memberRecord){
        return CommonResult.ok(memberService.buyEatMember(memberRecord));
    }

    /**
    * @Author G胖
    * @Description  后端管理---用户购买会员记录分页查询+模糊查（用户账号，开通会员名称。开通时间，过期时间）
    * @Date 2022-10-12 上午 10:55
    * @Return com.bgs.eat.page.PageResult

    */
    @GetMapping("/getMemberRecordByPage")
    public PageResult getMemberRecordByPage(PageRequest pageRequest,String userName,String memberName,String startOpenTime,String overOpenTime){
        return memberService.getMemberRecordByPage(pageRequest,userName,memberName,startOpenTime,overOpenTime);
    }
}
